package com.cy.pj.common.pagecontroller;

import com.cy.pj.common.utils.ShiroUtils;
import com.cy.pj.sys.pojo.Admin;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;


/*
 * 涉及到所有页面操作的;
 * */

@Controller
@RequestMapping("/")
public class PageController {
    /*
     * 项目总览页面;
     * http://localhost/doProjects
     * */
    @RequestMapping("doProjects")
    public String doProjects(Model model) {
        Admin user = ShiroUtils.getUser();
        model.addAttribute("user",user);
        return "projects";
    }



    /**
     * 初始页面页面;
     * http://localhost/doIndexUI
     */
    @RequestMapping("doIndexUI")
    public String doIndexUI(Model model) {
        Admin user = ShiroUtils.getUser();
        model.addAttribute("user",user);
        return "index";
    }

    /**
     * 点击更多,跳转到项目页面;
     */
    @RequestMapping("doProject")
    public String doProject(Model model) {
        Admin user = ShiroUtils.getUser();
        model.addAttribute("user",user);
        return "project";
    }

    /**
     * 发起项目页面;
     * http://localhost/doStart
     */
    @RequestMapping("doStart")
    public String doStart(Model model) {
        Admin user = ShiroUtils.getUser();
        model.addAttribute("user",user);
        return "start";
    }

    /**
     * 我的众筹页面;
     * http://localhost/doMinecrowdfunding
     */
    @RequestMapping("doMinecrowdfunding")
    public String doMinecrowdfunding(Model model) {
        Admin user = ShiroUtils.getUser();
        model.addAttribute("user",user);
        return "minecrowdfunding";
    }

    //rest风格的url定义
    //语法格式:/{a}/{b}/...;其中{}中的内容可以理解为一个变量
    //@PathVariable 注解用于获取url中与方法参数相同的变量值
    @RequestMapping("{moduleUI}")
    public String doModuleUI(@PathVariable String moduleUI,Model model){
        Admin user = ShiroUtils.getUser();
        model.addAttribute("user",user);
        return moduleUI;
    }


    @RequestMapping("doMenuUI")
    public String doMenuUI(Model model){
        Admin user = ShiroUtils.getUser();
        model.addAttribute("user",user);
        return "permission";
    }

    @RequestMapping("doLoginUI")
    public String doLoginUI(){
        return "login";
    }

    /**
     * 跳转管理员登录页面
     * @return
     */
    @RequestMapping("MainLogin")
    public String doMainLogin(Model model){
        Admin user = ShiroUtils.getUser();
        model.addAttribute("user",user);
        return "main";
    }

    /*
    @RequestMapping("UserUI")
    public String doUserUI(){
        return "user";
    }
    @RequestMapping("RoleUI")
    public String doRoleUI(){
        return "role";
    }
    @RequestMapping("PermissionUI")
    public String doPermissionUI(){
        return "permission";
    }
*/

}
